<script>
    
                /*
                    六、代码中监控内存

                                public static class MemoryMonitor
                                {
                                        public static void LogMemoryUsage(string stage)
                                        {
                                            long memory = GC.GetTotalMoemory(false);
                                            Console.WriteLine($"{stage}:{meemory/1024/1024} MB");

                                            // 获取各代GC统计
                                            for(int i=0;i<= GC.MaxGeneration;i++)
                                            {
                                                Console.WriteLine($"Gen {i} collection: {GC.CollectionCount(i)}");
                                            }
                                        }

                                        public static void ForceGCAndLog()
                                        {
                                            long before = GC.GetTotalMemory(true);
                                            GC.Collect();
                                            GC.WaiForPendingFinalizers();
                                            GC.Collect();
                                            long after = GC.GetTotalMemory(true);

                                            Console.WriteLine($"Memory after GC:{after / 1024 / 1024} MB");
                                            Console.WriteLine($"Freed: {(before -after) / 1024 / 1024} MB");
                                        }
                                }
                */
</script>